//
//  HLTnewusertitleCollectionViewCell.m
//  huiliantong
//
//  Created by hlt on 15/10/30.
//  Copyright © 2015年 hlt. All rights reserved.
//

#import "HLTnewusertitleCollectionViewCell.h"
#import "HLTzhanneixinTableViewController.h"
#import "HLTzhangdanViewController.h"
@implementation HLTnewusertitleCollectionViewCell




- (void)awakeFromNib {
    // Initialization code
}


-(void) initview
{
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    NSString *usertype;
    if ([acc.custFlag isEqual:@"4"]) {
        usertype=@"商户";
    }else
    {
        usertype=@"注册用户";
    }
    
    self.bangdingkahao.adjustsFontSizeToFitWidth = YES;
    
    self.usertype.text=usertype;
    self.userid.text=acc.custPhone;
    
    
    if ([acc.cardNo isEqual:@""]) {
        //        self.yue.hidden=YES;
        self.yue.text=@"无汇支付卡";
        self.bangdingkahao.text=@"您未绑定汇联通卡号，请选择卡绑定功能进行绑定";
        
        
    }
    else{
        self.yue.text= [NSString stringWithFormat:@"余额:%@",acc.YKTCardBalance];
        
        self.bangdingkahao.text= [NSString stringWithFormat:@"卡号:%@",acc.cardNo];
    }
    
    
    
    
}



- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // 初始化时加载collectionCell.xib文件 这个是把这个xib文件全部加载了，然后取第一个
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"HLTnewusertitleCollectionViewCell" owner:self options:nil];
        
        // 如果路径不存在，return nil
        if (arrayOfViews.count < 1)
        {
            return nil;
        }
        // 如果xib中view不属于UICollectionViewCell类，return nil
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]])
        {
            return nil;
        }
        // 加载nib
        self = [arrayOfViews objectAtIndex:0];
    }
    return self;
}


//- (IBAction)cancel:(id)sender {
//
//
//
//    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
//
//    //退出登录
//    [[AccountTool sharedAccountTool] tuichu:acc];
//
//    [self.parent viewWillDisappear:YES];
//    [self.parent viewWillAppear:YES];
//
//
//
//
//}







- (IBAction)jiaoyi:(id)sender {
    
    
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    HLTzhangdanViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTzhangdanViewController"];
    vc.jiaoyitype=@"xianshang";
    [self.parent.navigationController pushViewController:vc animated:YES]; //跳转到下一页面
    
    
    
    
    
    
    
    
    
    
    
    
}


#pragma mark slider的委托

-(void)sliderScrollerDidIndex:(NSInteger)index andSlider:(SliderViewController *)slider{
    
    NSString * tiitle=slider.titileArray[index];
    slider.title=tiitle;
}



//跳转到消息界面
- (IBAction)xiaoxi:(id)sender {
    
    UIView *view1=[[UIView alloc] initWithFrame:self.parent.view.bounds];
    view1.backgroundColor=[UIColor grayColor];
    view1.alpha=0.4;
    [self.parent.view addSubview:view1];
    MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
    indicatorView.delegate = self;
    indicatorView.numberOfCircles = 3;
    indicatorView.radius = 20;
    indicatorView.internalSpacing = 3;
    indicatorView.center = self.parent.view.center;
    [indicatorView startAnimating];
    [self.parent.view addSubview:indicatorView];
    
    
    Account *acc=[[AccountTool sharedAccountTool ]currentAccount];
    NSString *url=[myfriend stringByAppendingFormat:@"&username=%@",acc.custPhone];
    //将url转换一下格式，否则请求的格式就不兼容
    //    url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    [HLTNetWorkingtool getary:url success:^(NSArray *ary) {
        //        HLTFriendsTableViewController *vc=[[HLTFriendsTableViewController alloc]init];
        //        vc.friendlist=ary;
        //        vc.parent=self.parent;
        //        [self.parent.navigationController pushViewController:vc animated:YES]; //跳转到下一页面
        
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        HLTzhanneixinTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTzhanneixinTableViewController"];
        
        [self.parent.navigationController pushViewController:vc animated:YES]; //跳转到下一页面
        
        
        
    } faliure:^(NSString *error) {
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        
    }];
    
    
    
    
    
    
    
    
    
}




@end
